﻿using DeviceFaultPushService.DeviceProcessManagement.OperationManagement;
using DeviceFaultPushService.MessagePushService;
using DeviceFaultPushService.SystemService;

namespace DeviceFaultPushService;

/// <summary>
/// 入口启动
/// </summary>
public class StartUp : RunningServices
{
    public StartUp()
    {
        //拉起默认服务
        InitializeService();
    }
    public void Run(string id)
    {
        //Start(config);
        if (File.Exists($"json/{id}.json"))
        {
            string config = File.ReadAllText($"json/{id}.json");
            //开启服务
            Start(config);
        }
    }

    /// <summary>
    /// 初始化服务
    /// </summary>
    public void InitializeService()
    {
        //获取配置
        GetConfiguration.GetSettings();
        //消息推送服务
        if (GetConfiguration.Configuration.EnablePushService)
        {
            PushService.StartService();
            PushService.LogEvent += Log;
        }
        //语音播报服务
        if (GetConfiguration.Configuration.EnableVoiceBroadcastingService)
        {
            PlayService.StartService();
        }
    }

}